import 'package:json_annotation/json_annotation.dart';
import 'package:objectbox/objectbox.dart';

//数据库生成: flutter pub run build_runner build
//定义生成的文件 flutter pub run build_runner build --delete-conflicting-outputs
part 'models.g.dart';

//商品
@JsonSerializable(explicitToJson: true)
@Entity()
class BeanOfflineDBGood {
  @Id()
  int id=0;

  String? itemTypefCode;
  String? itemId;
  String? itemCode;
  String? itemName;
  String? skuBarcode;
  String? pinyin;//拼音首字母
  String? json;

  int version=0;//数据版本号

  BeanOfflineDBGood(
      {
        this.id=0,
        this.version=0,
        this.itemTypefCode,
        this.itemId,
        this.itemCode,
    this.itemName,
        this.skuBarcode,
        this.pinyin,
        this.json
      }
      );

  //添加固定格式
  factory BeanOfflineDBGood.fromJson(Map<String, dynamic> json) => _$BeanOfflineDBGoodFromJson(json);
  Map<String, dynamic> toJson() => _$BeanOfflineDBGoodToJson(this);

}

//商品规格
@JsonSerializable(explicitToJson: true)
@Entity()
class BeanOfflineDBGoodSpec {
  @Id()
  int id=0;
  String? itemId;
  String? specId;
  String? json;
  int version=0;//数据版本号

  BeanOfflineDBGoodSpec(
      {
    this.id=0,
    this.version=0,
    this.itemId,
    this.specId,
    this.json
  }
  );
  //添加固定格式
  factory BeanOfflineDBGoodSpec.fromJson(Map<String, dynamic> json) => _$BeanOfflineDBGoodSpecFromJson(json);
  Map<String, dynamic> toJson() => _$BeanOfflineDBGoodSpecToJson(this);

}

//订单
@JsonSerializable(explicitToJson: true)
@Entity()
class BeanOfflineDBOrder {
  @Id()
  int id=0;
  String? orderId;
  String? orderNo;
  String? orderDate;
  String? json;


  BeanOfflineDBOrder(
  {
    this.id=0, this.orderId, this.orderNo, this.orderDate, this.json
});

  //添加固定格式
  factory BeanOfflineDBOrder.fromJson(Map<String, dynamic> json) => _$BeanOfflineDBOrderFromJson(json);
  Map<String, dynamic> toJson() => _$BeanOfflineDBOrderToJson(this);

}

//挂单
@JsonSerializable(explicitToJson: true)
@Entity()
class BeanOfflineDBPendingOrder {
  @Id()
  int id=0;
  int? serialNumber;//流水号
  String? creatDate;
  String? totalMoney;
  String? json;


  BeanOfflineDBPendingOrder({this.id=0, this.serialNumber, this.creatDate,
    this.totalMoney, this.json});

  //添加固定格式
  factory BeanOfflineDBPendingOrder.fromJson(Map<String, dynamic> json) => _$BeanOfflineDBPendingOrderFromJson(json);
  Map<String, dynamic> toJson() => _$BeanOfflineDBPendingOrderToJson(this);

}




///////////////////////////////////////////////////

@Entity()
class TestDBItem {
  @Id()
  int id=0;
  String name;
  TestDBItem({required this.name});
}